
package Beans;

import BO.Service;
import UI.StatusUI;
import UI.UserUI;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

public class statusBean implements Serializable{

    private String statusMessage;
    private ArrayList<StatusUI> updates;
    
    public statusBean() {
    }

    public void addStatusMessage(){
        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        UserUI user = (UserUI)session.getAttribute("User");
        Service.addStatusMessage(user.getId(),statusMessage);
        statusMessage = "";
    }
    
    public ArrayList<StatusUI> getUpdates() {
         HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
         UserUI user = (UserUI)session.getAttribute("User");
         return Service.getStatusUpdates(user.getId());
    }

    public String getStatusMessage() {
        return statusMessage;
    }

    public void setStatusMessage(String statusMessage) {
        this.statusMessage = statusMessage;
    }
}
